package com.itheima;

import org.example.UserService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

@DisplayName("用户信息测试类")
public class UserServiceTest2 {

    private UserService userService;
    @BeforeEach
    public void setUp(){
        userService=new UserService();
    }

    @Test
    @DisplayName("获取性别为null")
    public void testGender1(){
        Assertions.assertThrows(IllegalArgumentException.class,()->{
            userService.getGender(null);
        });
    }

    @Test
    @DisplayName("idCard不符合")
    public void testGender2(){
        Assertions.assertThrows(IllegalArgumentException.class,()->{
            userService.getGender("10000000000000000000000000000000000000000");
        });
    }

    @DisplayName("性别测试类")
    @ParameterizedTest
    @ValueSource(strings = {"100000200010011011","100000200010011031","100000200010011051"})
    public void testGender2(String idCard){
        UserService userService=new UserService();
        String gender= userService.getGender(idCard);
        Assertions.assertEquals("男",gender);
    }
}
